clear all
set more off
cap log close

********************************************************************************
***** Project: The Short and Long Term Effects of In-Person Performance Feedback
********************************************************************************
***** A. R. Soetevent & G. J. Romensen
********************************************************************************
***** Cost/benefit analysis coaching
********************************************************************************

*global filepath "C:\JPEMicReplication"
*global paperpath "$filepath\TablesGraphs"


local abcd "acceleratie rem bochten fueleconomy"
log using "$filepath/Logs/X05CostBenefitAnalysisCoaching.log", replace

/*** Notes ***/
* No fuel economy observations postfeedback in urban area.

use "$filepath\DEPO\DataMainAnalysisDEPO.dta"

gen byte ZH = 0 
replace ZH = 1 if regio == "ZH"
gen byte FR = 0 
replace FR = 1 if regio == "FR"

** Drop data from ZH ** 
keep if FR == 1
*  Drop months with imperfect tracking by coaches 
*drop if datum>date("30-4-2016", "DMY")


* Calculate total nr. of km. per ``dienst'' on a given day
preserve
bysort datum dienst_nr: egen dienstkmdag=total(geplande_ritafstand)

* Drop duplicates
duplicates drop datum dienst_nr, force

** We are left with 111,991 days of service
sum dienstkmdag
** on average, drivers drive 200km a day	

*    Variable |        Obs        Mean    Std. Dev.       Min        Max
*-------------+---------------------------------------------------------
* dienstkmdag |    111,991    200900.9    435149.9          0   4.10e+07

** That is about all we need, 

** We can calculate how many drivers a coach on average approaches per day:
restore
preserve
keep if daysaftercoachingA0==1

duplicates drop datum chauf_nr_rug, force
bysort datum eco_coach_nr_rug: gen nrcoachsessies=_N
sum nrcoachsessies
*    Variable |        Obs        Mean    Std. Dev.       Min        Max
*-------------+---------------------------------------------------------
*nrcoachses~s |        241    2.170124    1.036872          1          5
restore

log close
